﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsmsExplorer.Infrastructure.EntityFactoryFramework;
using IsmsExplorer.Model.RiskRegister;
using IsmsExplorer.Infrastructure.Helper;

namespace IsmsExplorer.Infrastructure.Repositories.RiskRegister {
    internal class TreatmentFactory : IEntityFactory<Treatment> {
        internal static class FieldNames {
            public const string ID = "ID";
            public const string ProjectID = "ProjectID";
            public const string ThreatID = "ThreatID";
            public const string Reference = "Reference";
            public const string V = "V";
            public const string L = "L";
            public const string I = "I";
        } // end internal static class FieldNames

        public Treatment BuildEntity(System.Data.IDataReader reader) {
            return new Treatment() {
                ID = DataHelper.GetInteger(reader[FieldNames.ID]),
                ProjectID = DataHelper.GetInteger(reader[FieldNames.ProjectID]),                
                Reference = reader[FieldNames.Reference].ToString(),
                V = DataHelper.GetInteger(reader[FieldNames.V]),
                L = DataHelper.GetInteger(reader[FieldNames.L]),
                I = DataHelper.GetInteger(reader[FieldNames.I])
            };
        }

    }

    /// <summary>
    /// This class is only used for the constant names for table fields.
    /// It is not used to build any entity hence does not implement IEntityFactory<T>
    /// </summary>
    internal class TreatmentApplicationFactory {
        internal static class FieldNames {
            public const string ProjectID = "ProjectID";
            public const string TreatmentID = "TreatmentID";
            public const string ControlID = "ControlID";
        } // end internal static class FieldNames        
    }


}
